package com.jwd.config

import org.springframework.core.Ordered
import org.springframework.core.annotation.Order
import org.springframework.web.servlet.ModelAndView
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse

/**
 * Created by jin on 2017/3/10.
 */

@Order(Ordered.HIGHEST_PRECEDENCE + 1)
class MySessionFilter: HandlerInterceptorAdapter(){
    override fun preHandle(request: HttpServletRequest?, response: HttpServletResponse?, handler: Any?): Boolean {
        val session = request!!.getSession();

        if (session.getAttribute(MyWebMvcConfig.SESSION_KEY) == null) {
            return false;
        }
        return super.preHandle(request, response, handler)
    }
}